import {KEYBORD_KEY} from '@kernel/constant/keyboard'

export default class Keyboard {
  /**
   * 代码转字符串
   * @param code
   */
  static codeToStr(code: number): string | null {
    for (let key in KEYBORD_KEY) {
      if (KEYBORD_KEY[key] == code) {
        return key
      }
    }
    return null
  }

  /**
   * 字符串转代码
   * @param str
   */
  static strToCode(str: string): number {
    return KEYBORD_KEY[str] ?? 0
  }
}
